package com.xiyue.leaspring.resource.utils;

import java.io.IOException;
import java.util.Iterator;
import java.util.Scanner;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@ContextConfiguration(locations = {"classpath:spring/spring-base22.xml"})
@RunWith(SpringJUnit4ClassRunner.class)
public class DefaultResourceBeanTest2 {

	@Autowired
	public DefaultResourceBean2 resourceBean;
	
	
	@Test
	public void test() throws Exception {
		
		Iterator<Resource> iter = this.resourceBean.getResources().iterator();
		while (iter.hasNext()) {
			resourceOut(iter.next());
		}
		
	}

	public void resourceOut(Resource resource) throws IOException {
		Scanner scanner1 = new Scanner(resource.getInputStream());
		scanner1.useDelimiter("\n");
		while (scanner1.hasNext()) {
			System.out.print(scanner1.next());
		}
		scanner1.close();
		System.out.println();
		System.out.println("===================================");
	}

}
